<?php
session_start() ;
if(!isset($_SESSION["login"]) || $_SESSION["login"] == "")
{   
  header("Location: index.php?error=4") ;
}
require("fonctions.php");
$code=$_GET["error"];
$action = $_GET["action"];
if($lang=="FR"){
    $lang="FR";
    include("lang/fr_lang.php");
}elseif($lang=="EN"){
    $lang="EN";
    include("lang/en_lang.php");
}else{
    $lang="FR";
    include("lang/fr_lang.php");
}

?>

<html>
<head>
<title><?php echo TXT_TITLE;?></title>
 <link rel="stylesheet" type="text/css" href="style.css" >  
<script type="text/javascript">
//<![CDATA[

function valider() {
  // si la valeur du champ prenom est non vide
  if((document.form1.nom.value != "") && (document.form1.prenom.value != "") && (document.form1.email.value != "") && (document.form1.profil.value != "") && (document.form1.instit.value != "")) {
    // alors on envoie le formulaire
    document.form1.submit();
    return true;
  }
  else {
    // sinon on affiche un message
    alert("Remplir les champs obligatoires avant d'enregistrer svp !");
    return false;
  }

}
</script>
</head>

<body>
<?php require("menu.php");
?>
<br>
<?php echo error_message($code);?>
<div class="texte_acc">

<?php
if($action=="mod_user"){
   $id = $_GET["id"];
    
   $sql="select * from users where id=$id";
   $res  = mysql_query($sql);
   $r  = mysql_fetch_object($res);
    
    
    ?>
<form action="controler.php?action=mod_user" method="post" name="form1">
    <input name="id" type="hidden" value="<?php echo "$r->id";?>">
    <fieldset>
        <legend><?php echo TXT_USER_MOD;?></legend>
        
    
<TABLE class="">
    <tr>
        <td><?php echo TXT_NOM;?>*</td><td><input type="text" name="nom" size="45" value="<?php echo "$r->nom";?>"></td>
    </tr>
     <tr>
        <td><?php echo TXT_PRENOM;?>*</td><td><input type="text" name="prenom" size="45" value="<?php echo "$r->prenom";?>"></td>
    </tr> 
     <tr>
        <td><?php echo TXT_LOGIN;?>*</td><td><input type="text" name="login" size="45" value="<?php echo "$r->login";?>"></td>
    </tr> 
     <tr>
        <td><?php echo TXT_MOTDEPASSE;?></td><td><input type="password" name="password" size="45" value="<?php echo "$r->password";?>"></td>
    </tr> 
    
    <tr>
        <td><?php echo TXT_INSTITUTION;?>*</td><td><input type="text" name="instit" size="45" value="<?php echo "$r->instit";?>"></td>
    </tr> <tr>
        <td><?php echo TXT_PROFIL;?>*</td><td><select name="profil">
                <option>--</option>
                 <option value="USER" <?php if($r->profil=="USER") echo "selected";?>>USER</option>
                  <option value="ADMIN" <?php if($r->profil=="ADMIN") echo "selected";?>>ADMIN</option>
                  
            </select></td>
    </tr> <tr>
        <td><?php echo TXT_FONCTION;?></td><td><input type="text" name="fonction" size="45" value="<?php echo "$r->fonction";?>"></td>
    </tr> 
    <tr>
        <td><?php echo TXT_EMAIL;?>*</td><td><input type="text" name="email" size="45" value="<?php echo "$r->email";?>"></td>
    </tr> 
      <tr>
        <td><?php echo TXT_TELEPHONE;?>*</td><td><input type="text" name="tel" size="45" value="<?php echo "$r->tel";?>"></td>
    </tr> 
    <tr>
        <td colspan="2" align="center"><input type="submit" value="<?php echo TXT_SUBMIT;?>" onclick="return valider();"></td>
    </tr>
    
</table>
        </fieldset>
    </form>
<?php
}
?>




  
    
    
    
</div>

<?php
require_once ("footer.php");
?>